//	ID : pallab81
// 	PROG : 10943
// 	LANG : C++
// 	2011-08-31-14.28.15 Wednesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}

Int N,K;
const int mod = (int)1e6;
Int dp[101][101];

//s = now sum
//d = digit left
inline Int go(Int s, int k){
    if(s==0 && k==0){
        return 1LL;
    }
    if(k==0 && s!=0){
        return 0;
    }
    if( dp[s][k]!=-1 ){
        return dp[s][k];
    }
    int i;
    Int total=0;
    for(i=0;i<=N;++i){
        if(s-i<0)continue;
        total= (total%mod + go(s-i,k-1)%mod )%mod;
    }
    dp[s][k]=total;

return total;
}
inline void Proc(){
    SET(dp,-1);
    Int var = go(N,K);
    printf("%lld\n",var);
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","rt",stdin);
    #endif

    while( scanf("%lld %lld",&N,&K)==2 && (N!=0 && K!=0) ){
            Proc();
    }

return 0;
}
